previous contents   next

Appendix 2:
An approach to display ID of objects in VR browsers



1. An TOUCH PROTO node to visualise ID's of objects on a billboard.

The ID is visualised when the cursor is on an object. Two boxes on the snapshot are meant for objects. The TOUCH node changes the image with the ID of the shape according to the ID of the object.

Figure 1: A snapshot of the PROTO TOUCH node in action.

#VRML V2.0 utf8
#98-99
#S.Zlatanova#identification of objects

PROTO TOUCH [
        field     SFInt32     nodeID  0
        eventOut     MFString     string_changed
        ]

{

    DEF SENS TouchSensor {}
    #Script DEF NODE Script {
        url "javascript:
            function set_boolean (bool)
           {
                if ((bool == true)&&(nodeID == 1))
                        string_changed [0] = '1.jpg';
                if ((bool == true)&&(nodeID == 2))
                        string_changed [0] = '2.jpg';
                if ((bool == false)||(nodeID == 0))
                        string_changed [0] = 'x.jpg';
            }
        "

    eventIn SFBool set_boolean
    eventOut MFString string_changed IS string_changed
    field SFInt32 nodeID IS nodeID
    }

    ROUTE SENS.isOver TO NODE.set_boolean
}#TOUCH

Group {
    children [
       DEF Box1 TOUCH { nodeID 1 }
            Shape {
                appearance Appearance {
                    material Material {}
                }
                 geometry Box { size 0.1, 0.1, 0.1}
            }
]}

Transform {
    translation 2 0 0 children [
        DEF Box2 TOUCH { nodeID 2 }
            Shape {
                appearance Appearance {
                    material Material {}
                }
                geometry Box { size 0.1, 0.1, 0.1}
            }
]}

Billboard {
    children[
        Shape {
            appearance Appearance {
                material Material {}
                texture DEF TEXT ImageTexture {}
            }
            geometry IndexedFaceSet {
                coord Coordinate {
                    point[ 0 0 0, 1 0 0, 1 1 0, 0 1 0, ]
                }
                coordIndex [0,1,2,3,]
           }
        }
      ]
    axisOfRotation 0.0 1.0 0.0
}

#changing texture

ROUTE Box1.string_changed TO TEXT.set_urlROUTE Box2.string_changed TO TEXT.set_url

The same node can be realised by using the TEXT shape instead of billboards (see VRML)

2. Display of ID's without the designed PROTO node (text shapes are used instead of billboards).

The corresponding lines needed for the same operation are given in a bolt font in both variants.

#VRML V2.0 utf8
#98-99
#S. Zlatanova
#identification of objects

Group{
    children[
        Transform {
            children[
                DEF Box1 TouchSensor {}
                  Shape {
                          appearance Appearance {
                               material Material {}
                            }
                            geometry Box {
                                size 0.1, 0.1, 0.1}
                            }
        ]}
           Transform {
           translation 3 0 0
                    children[
                   DEF Box2 TouchSensor {}
                               Shape {
                                    appearance Appearance {
                                        material Material {
                                            diffuseColor 0.60 0.20 0.30
                                        }
                                    }
                                    geometry Box {
                                        size 0.1, 0.1, 0.1}
                                }
             ]}
            Shape {
            appearance Appearance {
                    material Material {}
                 }
                 geometry DEF TEXT Text {
                    length [1,6]}
            }

#Script
DEF Node1 Script {
    url "javascript:
        function set_boolean (bool)
        {
            if (bool == true)
            string_changed [0] = '21';
            if (bool == false)
            string_changed [0] = ' ';
        }
    "
eventIn SFBool set_boolean
eventOut MFString string_changed
}

DEF Node2 Script {
    url "javascript:
        function set_boolean (bool)
        {
            if (bool == true)
            string_changed [0] = '22';
            if (bool == false)
            string_changed [0] = ' ';
      }
    "

eventIn SFBool set_boolean
eventOut MFString string_changed
}

]}

#changing text
ROUTE Box1.isOver TO Node1.set_boolean
ROUTE Node1.string_changed TO TEXT.set_string
ROUTE Box2.isOver TO Node2.set_boolean
ROUTE Node2.string_changed TO TEXT.set_string



previous  contents  next